package com.lemon.smartsafety.ui.adapter.user;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.entity.user.ScoreLogVo;
import com.lemon.smartsafety.utils.common.DateUtils;
import com.lemon.smartsafety.utils.common.StringUtils;

import java.util.List;

import kale.adapter.LemonRcvAdapter;
import kale.adapter.item.AdapterItem;

/**
 * Created by Cooliean on 16/3/29.
 */
public class MyScoreAdapter extends LemonRcvAdapter<ScoreLogVo> {
    public MyScoreAdapter(@Nullable List<ScoreLogVo> data) {
        super(data);
    }

    @NonNull
    @Override
    public AdapterItem createItem(Object type) {
        return new MyScoreItem();
    }

    public class MyScoreItem implements AdapterItem<ScoreLogVo> {
        TextView tvTitle;
        TextView tvSubTitle;


        @Override
        public int getLayoutResId() {
            return R.layout.item_score_list;
        }

        @Override
        public void bindViews(View root) {
            tvTitle = (TextView) root.findViewById(R.id.tv_title);
            tvSubTitle = (TextView) root.findViewById(R.id.tv_sub_title);

        }

        @Override
        public void setViews() {
        }

        @Override
        public void handleData(ScoreLogVo data, int position) {
            tvTitle.setText(String.format("%s %s分", data.getRemark(), StringUtils.nullValue(data.getLogScore(), "0")));
            tvSubTitle.setText(DateUtils.getFormatDateStringWithDateString(data.getLogDate(),DateUtils.dateFormatYMDHM));
        }
    }
}
